package com.mfl.controller.user;

import com.mfl.common.PageResult;
import com.mfl.common.Result;
import com.mfl.pojo.dto.RemarkDTO;
import com.mfl.pojo.dto.RemarkPageQueryDTO;
import com.mfl.service.RemarkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("userRemarkController")
@RequestMapping("/cky/user/remark")
@Slf4j
public class RemarkController {

    @Autowired
    private RemarkService remarkService;

    /**
     * 新增评论
     * @param remarkDTO
     * @return
     */
    @PostMapping("/insert")
    public Result insert(@RequestBody RemarkDTO remarkDTO){
        log.info("新增评论：{}", remarkDTO);
        remarkService.insert(remarkDTO);
        return Result.success("评论成功");
    }

    /**
     * 分页查询评论
     * @param remarkPageQueryDTO
     * @return
     */
    @GetMapping("/pageQueryRemark")
    public Result<PageResult> pageQueryRemark(RemarkPageQueryDTO remarkPageQueryDTO){
        log.info("分页查询评论：{}", remarkPageQueryDTO);
        PageResult pageResult = remarkService.pageQuery(remarkPageQueryDTO);
        return Result.success("",pageResult);
    }
}
